#include "listitem.h"
#include "ui_listitem.h"

ListItem::ListItem(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ListItem),isLike(false)
{
    ui->setupUi(this);
}

ListItem::~ListItem()
{
    delete ui;
}

void ListItem::enterEvent(QEvent *event)
{
    this->setStyleSheet("background-color:#EFEFEF;");
    (void)event;
}

void ListItem::leaveEvent(QEvent *event)
{
    this->setStyleSheet("");
    (void)event;
}

void ListItem::setMusicName(const QString &musicName)
{
    ui->musicNameLabel->setText(musicName);
}

void ListItem::setMusicSinger(const QString &musicSinger)
{
    ui->musicSingerNameLabel->setText(musicSinger);
}

void ListItem::setMusicAlbum(const QString &musicAlbum)
{
    ui->albumNameLabel->setText(musicAlbum);
}

void ListItem::setMusicLike(bool like)
{
    isLike = like;
    if(isLike)
    {
        ui->likeBt->setIcon(QIcon(":/image/like_2.png"));
    }
    else
    {
        ui->likeBt->setIcon(QIcon(":/image/like_3.png"));
    }
}

void ListItem::on_likeBt_clicked()
{
    isLike = !isLike;
    //调用函数，更新按钮图片；
    this->setMusicLike(isLike);
    //当按钮点击时，页面需要进行更新；发送信号进行处理；
    emit setIsLike(isLike);

}
